﻿namespace designpatternsplusplus.regressions
{
    #region

    using System;
    using System.Collections.ObjectModel;
    using System.Net;
    using System.Security.Principal;
    using CoolCrapService;
    using decorator.DomainEntities;
    using designpatternsplus.contracts;

    #endregion

    public static class Startup
    {
        static void Main(string[] args)
        {
            var _client = GetServiceWithToken();


            var skus = new Collection<String>
                (new[]
                 {
                     "75173395EB274d7bB51B149E8144B6FE",
                     "5FB5B42F99954d7186CDCF5AC26C2FD3",
                     "0FBE1DD511F243acBF6099B929A595BD",
                     "A77727F541604a0cBDD416689E486869"
                 });

            var myReceipt = _client.ProcesShoppingCart(skus) as ISalesReceipt;

            if (myReceipt != null)
            {
                RegressionModel.ToViewWithAssert(() => myReceipt.TotalTax, 6.70, "Tax");
                RegressionModel.ToViewWithAssert(() => myReceipt.TotalSale, 74.68, "Sale");

                myReceipt.Validate(false, 32.19, 20.89, 9.75, 11.85);
            }
        }


        static MarketServiceClient GetServiceWithToken() {

            var _client = new MarketServiceClient();
            var _cred = _client.ClientCredentials.Windows;
            _cred.AllowNtlm = true;
            _cred.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
            _cred.ClientCredential = new NetworkCredential("damon", "sailor");

            _client.Open();

            return _client;
           
        }
    }
}